// noinspection DuplicatedCode

import pluginVue from 'eslint-plugin-vue'
import { defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript'
import skipFormatting from '@vue/eslint-config-prettier/skip-formatting'
import pluginImportX from 'eslint-plugin-import-x'
import { createTypeScriptImportResolver } from 'eslint-import-resolver-typescript'

// To allow more languages other than `ts` in `.vue` files, uncomment the following lines:
// import { configureVueProject } from '@vue/eslint-config-typescript'
// configureVueProject({ scriptLangs: ['ts', 'tsx'] })
// More info at https://github.com/vuejs/eslint-config-typescript/#advanced-setup

export default defineConfigWithVueTs(
  {
    name: 'app/files-to-lint',
    files: ['**/*.{ts,mts,tsx,vue}'],
  },

  {
    name: 'app/files-to-ignore',
    ignores: ['**/dist/**', '**/dist-ssr/**', '**/coverage/**'],
  },

  pluginVue.configs['flat/essential'],
  vueTsConfigs.recommended,
  skipFormatting,

  // Ignore scripts directory.
  {
    name: 'app/scripts-to-ignore',
    ignores: ['scripts/**'],
  },

  // Check import like case-sensitive.
  {
    name: 'app/import-check',
    plugins: {
      'import-x': pluginImportX,
    },
    settings: {
      'import-x/resolver-next': [
        createTypeScriptImportResolver({
          project: 'tsconfig.app.json',
          noWarnOnMultipleProjects: true,
        }),
      ],
    },
    rules: {
      'import-x/no-unresolved': ['error', { caseSensitive: true }],
      'import-x/consistent-type-specifier-style': ['error', 'prefer-inline'],
    },
  },
)
